
from read import *
from utils_math import *



zoom_cur = 18
num = 2
cv2.namedWindow('image', cv2.WINDOW_NORMAL)  

# 自己参考坐标
# 15公寓
x, y = LatLongToTileXY(DegreesMinutesSeconds2Decimal(126., 40., 55.), DegreesMinutesSeconds2Decimal(45, 46, 15), zoom_cur)
# 61号楼
x, y = LatLongToTileXY(DegreesMinutesSeconds2Decimal(126., 40., 74.), DegreesMinutesSeconds2Decimal(45, 46, 35), zoom_cur)




while(True):
    pic_list = find_rectangle_area(x, y, num, num)
    imgs, names = loadingImage("../map", zoom_cur, pic_list)
    image_ret = merge_images(imgs, names)

    cv2.imshow("image", image_ret)
    
    key = cv2.waitKey(30)
    if key == ord('w'):
        y -= 1
    elif key == ord('a'):
        x -= 1
    elif key == ord('s'):
        y += 1
    elif key == ord('d'):
        x += 1
    elif key == ord(' '):
        cv2.imwrite("../result/save.png", image_ret)
